<template>
    <div class="app-container"
         v-loading.fullscreen.lock="allLoading"
         element-loading-text="拼命处理中,请耐心等待"
         element-loading-spinner="el-icon-loading"
         element-loading-background="rgba(0, 0, 0, 0.8)"
    >

<!--    调用 geMainList   -->
        <autumn-table-el :main-table="mainTable" @refresh="getMainList">
            <template slot="top">
                <el-col :span="1.5">
                    <el-button
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="handleAdd"
                    >新建</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button
                        type="success"
                        icon="el-icon-edit"
                        size="mini"
                        :disabled="!relationshipParserToString(mainTable,`currentRow.autumnAppId`)"
                        @click="handleEditTable(mainTable.currentRow)"
                    >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button
                        type="danger"
                        icon="el-icon-delete"
                        size="mini"
                        :disabled="mainTable.multiple"
                        @click="handleDelete"
                    >删除</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button
                        type="info"
                        size="mini"
                        @click="handleTest"
                    >测试</el-button>
                </el-col>
            </template>
            <template slot="default">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column
                    label="编号"
                    align="center" prop="autumnAppId" />
                <el-table-column
                    label="表名称"
                    align="center" prop="tableName" />
                <el-table-column
                    label="应用名称"
                    align="center" prop="appName" />
                <el-table-column
                    label="应用描述"
                    align="center" prop="description" />
                <el-table-column
                    label="应用类型"
                    align="center" prop="appType" />
                <el-table-column
                    label="功能位选项"
                    align="center" prop="functionOption" />
                <el-table-column
                    label="创建者"
                    align="center" prop="createBy" />
                <el-table-column label="创建时间" align="center" prop="createTime" width="180">
                    <template slot-scope="scope">
                        <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="更新者"
                    align="center" prop="updateBy" />
                <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
                    <template slot-scope="scope">
                        <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="备注"
                    align="center" prop="remark" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-delete"
                            @click="handleDelete(scope.row)"
                        >删除</el-button>
                    </template>
                </el-table-column>
            </template>
        </autumn-table-el>

        <AutumnAppAddFormDialog ref="autumnAppAddFormDialog" @close="getMainList"></AutumnAppAddFormDialog>
    </div>
</template>

<script>



import { autumnPageMixin } from '/src/components/autumn/autumn-page'
import { listTable } from '../../../api/tool/gen'
import { getRandomInt } from '../../../utils/wangbao-random'
import { delAutumnApp, getAutumnApp, listAutumnApp } from '../../../api/tool/autumnApp'
import AutumnAppAddFormDialog from "./AutumnAppAddFormDialog"
import request from '../../../utils/request'

export default {
    name: "autumnApp",
    mixins: [autumnPageMixin],
    components: {
        AutumnAppAddFormDialog,
    },
    data() {
        return {
        };
    },
    methods: {
        initMainTableParam(){
            return {
                uniqueId: 'autumnAppId',
                showSearch: false,
                showSearchButton: false,
            }
        },
        getMainListRemote(queryParams){
            return listAutumnApp(queryParams)
        },
        //处理成功的数据,兼容的
        handleSuccessList(res){
            console.log("getMainListSuccess",res)
            return {
                data: {
                    list: res.rows,
                    total: res.total,
                }
            }
        },
        handleAdd(){
            this.$refs.autumnAppAddFormDialog.show({
                virtualChangeBitFlag: this.CHANGE_BIT_FLAG.add,
            })
        },
        handleEditTable(row){
            getAutumnApp(row.autumnAppId).then(res=>{
                this.$refs.autumnAppAddFormDialog.show({
                    form: res.data,
                    title: '修改',
                    virtualChangeBitFlag: this.CHANGE_BIT_FLAG.modify,
                })
            })
        },
        handleDelete(row){
            const ids = row.autumnAppId || this.mainTable.ids;
            this.$confirm('是否确认删除采购送货单编号为"' + ids + '"的数据项?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function() {
                return delAutumnApp(ids);
            }).then(() => {
                this.getMainList();
                this.msgSuccess("删除成功");
            })
        },
        handleTest(){
            request({
                url: '/tool/AutumnApp/test',
                method: 'post'
            })
        }
    }
};
</script>

<style lange='less'>
</style>
